package com.hhd.pdf.components;

import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class InlineComponentFinder {
    @Autowired
    @Lazy
    @Getter
    List<InLineComponent> inLineComponents;

    static InlineComponentFinder components;

    public InlineComponentFinder() {
        components = this;
    }

    public static InLineComponent getComponent(String name) {
        for (InLineComponent inLineComponent : components.getInLineComponents()) {
            if (inLineComponent.getName().equals(name)) {
                return inLineComponent;
            }
        }
        return null;
    }
}
